<template>
  <div class="app-container">
    <el-dialog :title="title" :visible.sync="dialogVisible" width="60%" @close="closed">
      <div class="detailContainer">
        <div v-for="item in fileds" :key="item.key" class="detailItem">
          <div v-if="item.key === 'buyType'">
            <span class="detailTitle">{{ item.lable }}：</span>
            <span class="detailContent">{{ buyTypeMap[currents[item.key]] }}</span>
          </div>
          <div v-else-if="item.key === 'localInvoicing'">
            <span class="detailTitle">{{ item.lable }}：</span>
            <span class="detailContent">{{ localInvoicingMap[currents[item.key]] }}</span>
          </div>
          <div v-else-if="item.key === 'alarmSendStatus'">
            <span class="detailTitle">{{ item.lable }}：</span>
            <span class="detailContent">{{ alarmSendStatusMap[currents[item.key]] }}</span>
          </div>
          <div v-else-if="item.key === 'appealHandleStatus'">
            <span class="detailTitle">{{ item.lable }}：</span>
            <span class="detailContent">{{ appealHandleMap[currents[item.key]] }}</span>
          </div>
          <div v-else-if="item.key === 'useType'">
            <span class="detailTitle">{{ item.lable }}：</span>
            <span class="detailContent">{{ useTypeMap[currents[item.key]] }}</span>
          </div>
          <div v-else-if="item.key === 'appealStatus'">
            <span class="detailTitle">{{ item.lable }}：</span>
            <span class="detailContent">{{ appealStatusMap[currents[item.key]] }}</span>
          </div>
          <div v-else-if="item.key === 'spanBigArea'">
            <span class="detailTitle">{{ item.lable }}：</span>
            <span class="detailContent">{{ spanBigAreaMap[currents[item.key]] }}</span>
          </div>
          <div v-else>
            <span class="detailTitle">{{ item.lable }}：</span>
            <span class="detailContent">{{ currents[item.key] }}</span>
          </div>
        </div>
      </div>
      <div v-if="title === '详情'" slot="footer" class="dialog-footer" style="text-align: center;">
        <el-button type="primary" @click="closed">确 认</el-button>
      </div>
      <slot />
    </el-dialog>
  </div>
</template>
<script>
import {
  alarmSendStatusMap,
  buyTypeMap,
  localInvoicingMap,
  appealHandleMap,
  appealStatusMap,
  spanBigAreaMap,
  useTypeMap,
  getStorageByKey } from '@/utils/public'
export default {
  name: 'DetailDialog',
  props: {
    currents: {
      type: Object,
      default() {
        return {}
      }
    },
    fileds: {
      type: Array,
      default() {
        return []
      }
    },
    dialogVisible: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: '详情'
    }
  },
  data() {
    return {
      alarmTypeMap: getStorageByKey('alarmTypeMap') || [],
      alarmSendStatusMap,
      buyTypeMap,
      localInvoicingMap,
      appealHandleMap,
      appealStatusMap,
      spanBigAreaMap,
      useTypeMap
    }
  },
  created() {
  },
  methods: {
    closed() {
      this.$emit('close')
    }
  }
}
</script>
<style lang="scss" scoped>
.detailContainer {
    display: flex;
    flex-wrap: wrap;
    padding: 0 15px;
    width: 100%;
    max-height: 400px;
    overflow-y: scroll;
    .detailItem{
        width: 33%;
        min-height: 50px;
        div{
            display: flex;
        }
        .detailTitle{
            font-weight: bold;
            display: inline-block;
            max-width: 120px;
            min-width: 60px;
        }
    }
}
</style>
